package com.example.qy160demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.qy160demo.entity.Emp;
import com.example.qy160demo.service.EmpService;
import com.example.qy160demo.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/emp")
@Api(tags = "员工接口类")
@CrossOrigin
public class EmpController {

    @Autowired
    private EmpService empService;


    @GetMapping("getAll/{currentPage}/{pageSize}")
    @ApiOperation(value = "分页查询员工信息")
    public Result<IPage<Emp>> getAll(@ApiParam(value = "当前页码") @PathVariable(value = "currentPage")Integer currentPage,
                                     @ApiParam(value = "每页个数",required = true) @PathVariable Integer pageSize){
        return empService.listByPage(currentPage, pageSize);
    }

    @DeleteMapping("del/{empno}")
    @ApiOperation(value = "删除员工信息")
    public Result<IPage<Emp>> delemp(@ApiParam(value = "员工编号") @PathVariable(value = "empno")Integer empno){
        return empService.delemp(empno);
    }

}
